//
//  QZMyTitleView.m
//  shortvideoplay
//
//  Created by adam on 2024/9/22.
//

#import "QZMyTitleView.h"
#import "QZMyTitleCell.h"
#import "QZMyTitleCellModel.h"

@implementation QZMyTitleView
- (Class)preferredCellClass {
    return [QZMyTitleCell class];
}
- (void)refreshDataSource {
//    if (self.dataSource == nil) {
        NSMutableArray *tempArray = [NSMutableArray array];
        for (int i = 0; i < self.titles.count; i++) {
            QZMyTitleCellModel *cellModel = [[QZMyTitleCellModel alloc] init];
            cellModel.imgName_nor = self.imgName_nor;
            cellModel.imgName_sel = self.imgName_sel;
            if(_imgIndexArr.count > i && [_imgIndexArr[i] intValue] == 1){
                cellModel.hiddeImg = NO;
            }else{
                cellModel.hiddeImg = YES;
            }
            [tempArray addObject:cellModel];
        }
        self.dataSource = tempArray;
//    }
}

- (CGFloat)preferredCellWidthAtIndex:(NSInteger)index {
    CGFloat cellWidth = [super preferredCellWidthAtIndex:index];
    if (self.dataSource != nil && self.dataSource.count > index) {
        ((QZMyTitleCellModel *)self.dataSource[index]).cellWidth = cellWidth;
    }
    return cellWidth;
}


@end
